#define _CRT_SECURE_NO_WARNINGS 1


#include<iostream>

using namespace std;

int Func(int n)
{
	int count = 0;
	while (n)
	{
		if (n % 10 == 2)
		{
			count++;
		}
		n /= 10;
	}
	return count;
}

int main()
{
	int left = 0, right = 0;
	cin >> left >> right;
	int count = 0;
	for (int i = left; i <= right; i++)
	{
		count += Func(i);
	}
	cout << count << endl;

	return 0;
}